import 'package:flutter/material.dart';
import 'package:flutter_09_game/base/widget/base_list_more_get_builder.dart';
import 'package:flutter_09_game/config/app_color.dart';
import 'package:flutter_09_game/generated/assets.dart';
import 'package:flutter_09_game/generated/locales.g.dart';
import 'package:flutter_09_game/pages/profile/profile_bet_record/models/model_game_round_join.dart';
import 'package:flutter_09_game/pages/profile/profile_bet_record/utils_bet_record.dart';
import 'package:flutter_09_game/pages/profile/profile_bet_record/widgets/widget_bet_record_bet_item.dart';
import 'package:flutter_09_game/pages/profile/profile_bet_record/widgets/widget_bet_record_dropdown.dart';
import 'package:flutter_09_game/pages/profile/profile_bet_record/widgets/widget_bet_record_dropdown_game.dart';
import 'package:flutter_09_game/pages/profile/profile_bet_record/widgets/widget_bet_record_top_crypto.dart';
import 'package:flutter_09_game/pages/profile/profile_bet_record/widgets/widget_game_stats.dart';
import 'package:flutter_09_game/pages/profile/profile_bet_record/widgets/widget_bet_record_item.dart';
import 'package:flutter_09_game/widgets/btn_dropdown.dart';
import 'package:flutter_09_game/widgets/empty/empty_no_data.dart';
import 'package:flutter_09_game/widgets/image/auto_image.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'profile_bet_record_battle_logic.dart';

class ProfileBetRecordBattlePage extends StatelessWidget {
  ProfileBetRecordBattlePage({super.key});

  final ProfileBetRecordBattleLogic logic =
      Get.put(ProfileBetRecordBattleLogic());

  @override
  Widget build(BuildContext context) {
    return BaseListMoreGetBuilder<ProfileBetRecordBattleLogic>(
        bodyTopViewBuilder: (_) {
      return Obx(() {
        return WidgetBetRecordDropdownGame(
          teamRows: UtilsBetRecord.options,
          teamRx: logic.selectorTagRx,
          statusRows: UtilsBetRecord.betStatusRows,
          timeRows: UtilsBetRecord.timeRows,
          timeRx: logic.timeRx,
          statusRx: logic.statusRx,
          gameRows: logic.gameRows,
          gameRx: logic.gameRx,
          editingController: logic.codeController,
          userEditingController:
              UtilsBetRecord.options.indexOf(logic.selectorTagRx.value) == 0
                  ? null
                  : logic.userController,
          onRequestRefresh: (value) {
            logic.refreshController.requestRefresh();
          },
          onTimeSelection: (value) {
            logic.updateTimeSelection(value);
          },
        );
      });
    }, headerBuilder: (_) {
      return Visibility(
          visible: (logic.recordBattle.stats ?? []).isNotEmpty,
          child: WidgetGameStats(
            stats: logic.recordBattle.stats ?? [],
          ).marginOnly(top: 16.w, left: 16.w, right: 16.w)
          // showTRX: joinType == 2,
          );
    }, builder: (_) {
      return logic.list.isNotEmpty
          ? SliverPadding(
              padding:
                  EdgeInsets.only(bottom: 16.w + ScreenUtil().bottomBarHeight),
              sliver: SliverList.builder(
                itemCount: logic.list.length,
                itemBuilder: (context, index) {
                  final item = logic.list[index];
                  return WidgetBetRecordBetItem(
                    data: item,
                  );
                },
              ))
          : SliverToBoxAdapter(
              child: SizedBox(
                width: 1.sw,
                child: Padding(
                  padding: EdgeInsets.only(top: 108.w),
                  child: EmptyNoData.notDataView(),
                ),
              ),
              // )
              // ],
            );
    });
  }
}
